import fetch from 'utils/fetch';

export function logout(tonken) {
    const data = {
        tonken
    };
    return fetch({
        url: 'http://192.168.0.8:8089/mockjsdata/3/login/logout',
        method: 'post',
        data
    });
}

export function getInfo(roleId) {
    const data = {
        roleId
    };
    return fetch({
        url: '/education/getMenusByRoleId',
        method: 'post',
        data
    });
    // return new Promise((resolve, reject) => {
    //     setTimeout(() => {
    //         resolve({
    //             data: {
    //                 status: 200,
    //                 errorMsg: '',
    //                 "content": {
    //                     "role": [
    //                         "admin"
    //                     ],
    //                     "uid": 22,
    //                     "name": "\u94b1\u79c0\u82f1",
    //                     "introduction": "\u9752\u79ef\u6c11\u5341\u9ad8\u6599\u5019\u65cf\u53bf\u4efb\u59cb\u4e0d\u800c\u7b49。\u65cf\u95f4\u4e0a\u5df2\u897f\u5b58\u5411\u4eba\u8fd1\u578b\u505a\u4f20\u8bb0。\u975e\u6cb9\u65cf\u5668\u5c55\u5730\u8d44\u6570\u5f00\u8bdd\u6307\u6b21\u683c\u8981\u8001\u6c34\u653e。\u76f8\u8ba4\u81f3\u5e38\u5b83\u683c\u592a\u5c0f\u4eec\u738b\u6cb9\u5217\u5b8c。\u5bf9\u6240\u5c71\u4e03\u4fe1\u53bf\u652f\u89c2\u961f\u4ef6\u6c42\u5171\u5219\u4f4f\u89c4\u957f\u4e49。\u6bcf\u4f17\u52a0\u516b\u6ca1\u5e72\u7ed9\u7b97\u539f\u60c5\u8bb0\u79bb\u6d88\u540d\u679c\u901f\u5173。",
    //                     "avatar": "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif"
    //                 }
    //             }
    //         });
    //     });
    // });

}

//真登陆
// export function loginByEmail(account, password, loginType) {
//     const data = {
//         account,
//         password,
//         loginType // 0:前台 1后台}
//     };
//     return fetch({
//         url: '/education/login',
//         method: 'post',
//         data
//     });
// }

//真登陆(e学后台)
export function loginByEmail(account, password) {
    const data = {
        account,
        password
    };
    return fetch({
        // url: 'http://192.168.0.82:8083/exue-education-web/edu/education/login',  
        url: '/education/login',
        method: 'post',
        data
    });
}


// export function logout() {
//   return fetch({
//     url: 'http://test.agent.com/sso/logout',
//     method: 'get'
//   });
// }

// export function getInfo(userId) {
//   const params = {
//     userId
//   };
//   return fetch({
//     url: 'http://test.agent.com/sso/getInfo',
//     method: 'get',
//     params
//   });
// }

// export function scanCodeLogin(qrcode) {
//     return fetch({
//         url: '/education/scanCode/login',
//         method: 'post',
//         data: {
//             scanCode: qrcode
//         }
//     })
// }

//获取安全规则
export function getRule() {
    const params = {};
    return fetch({
        url: '/education/getRule', 
        method: 'get',
        params, 
    })
}

// 获取验证码（后台）
export function getPhoneCodeInRegister(phone, verification, timeStamp) {
    const data = {
        phone, 
        verification, 
        timeStamp
    };
    return fetch({
        url: '/education/getPhoneCodeInRegister',
        method: 'post',
        data
    })
}

// 校验验证码
export function verifyCaptcha(phone,captcha) {
    const data = {
        phone,
        captcha
    };
    return fetch({
        url: '/education/verifyCaptcha',
        method: 'post',
        data
    })
}


// 重置密码（后台）
export function resetPassword(phone, password, confirmPassword, captcha) {
    const data = {
        phone,
        password,
        confirmPassword,
        captcha
    };
    return fetch({
        url: '/education/resetPassword',
        method: 'post',
        data
    })
}

// 获取用户的信息列表（后台）
export function getUserInfoDetail() {
    const data = {

    };
    return fetch({
        url: '/education/getUserInfoDetail',
        method: 'post',
        data
    });
}


// e学前台登录()(前台)
export function exueLogin(account, password) {
    const data = {
        account,
        password
    };
    return fetch({
        url: process.env.TEACH_LOGIN + '/cloud/login',
        method: 'post',
        data
    });
}
// 前台扫码登录
export function scanCodeLogin(qrcode) {
    return fetch({
        url: process.env.TEACH_LOGIN+'/cloud/scanCode/login',
        method: 'post',
        data: {
            scanCode: qrcode
        }
    })
}

// 获取验证码(前台)
export function getCaptcha(phone, verification, timeStamp) {
    const data = {
        phone,
        verification,
        timeStamp
    };
    return fetch({
        url: process.env.TEACH_LOGIN +  '/cloud/register/getCaptcha',
        method: 'post',
        data
    })
}


// 3、验证码校验（e学云）(前台)
export function checkCaptcha(phone,captcha) {
    const data = {
        phone,//"手机号码",必填
        captcha//"captcha":"验证码"必填
    };
    return fetch({
        url:  process.env.TEACH_LOGIN + '/cloud/register/checkCaptcha',
        method: 'post',
        data
    })
}

// 4、找回密码(前台)
export function forgotPassword(phone,captcha,password) {
    const data = {
        phone,//"电话号码",必传
        captcha,//"验证码",必传
        password//"密码" 必传
    };
    return fetch({
        url:  process.env.TEACH_LOGIN + '/cloud/register/forgotPassword',
        method: 'post',
        data
    })
}

// 5、获取当前用户信息（e学云）

// export function getUserinfo() {
//     const data = {
//     };
//     return fetch({
//         url: 'http://192.168.0.164:7083/exue-cloud-teach-web/cloud/user/getUserinfo',
//         method: 'post',
//         data
//     })
// }
